Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buildLinux: Fix result derivation overriding with passthru via stdenv.mkDerivation instead of lib.extendDerivation #288154

Merged
merged 1 commit into from
Feb 26, 2024

Conversation

ShamrockLee
Copy link
Contributor

@ShamrockLee ShamrockLee commented Feb 11, 2024

Description of changes

The buildLinux build helper currently relies on lib.extendDerivation to attach passthru attributes to each outputs. As lib.extendDerivation doesn't handle overriders correctly (#288148), the passthru arguments will be lost when overriding the kernel packages.

This PR fixes this issues by overriding the derivation returned by manual-config.nix with <pkg>.overrideAttrs, and update passthru to pass the attributes.

Aside from fixing the attribute-lost-after-overriding issue, this changes also enable the passthru attributes overriding with <pkg>.overrideAttrs and allow passthru.tests test cases to reference finalAttrs.passthru.tests.

This PR would conflict with #287659, but such conflict is trivial to resolve, and I'll do the rebase once any one of them gets merged.

Fixes: #111504
Previous attempt: #149455

Things done

  • Built on platform(s)
    • x86_64-linux (no known rebuilds)
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.05 Release Notes (or backporting 23.05 and 23.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added the 6.topic: kernel The Linux kernel label Feb 11, 2024
@ShamrockLee
Copy link
Contributor Author

Result of nixpkgs-review run on x86_64-linux 1

@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild 10.rebuild-linux: 0 This PR does not cause any packages to rebuild labels Feb 11, 2024
@ShamrockLee
Copy link
Contributor Author

@ofborg build linux linux.tests

Copy link
Member

@infinisil infinisil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested this and it seems to be working well, nice job! And it's much nicer than by previous attempt 😄

For future reference, an example of what works now is testing kernel overrides like this:

(linuxPackages.kernel.overrideAttrs (old: {
  # Some changes
})).tests

@infinisil infinisil merged commit 548a86b into NixOS:master Feb 26, 2024
26 checks passed
@ShamrockLee ShamrockLee deleted the linux-kernel-passthru branch February 26, 2024 22:27
@ShamrockLee
Copy link
Contributor Author

Thank you @infinisil for testing and merging!

The fix utilize finalAttrs.finalPackage provided by #119942, which makes things much easier than the previous take.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: kernel The Linux kernel 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild 10.rebuild-linux: 0 This PR does not cause any packages to rebuild
Projects
None yet
Development

Successfully merging this pull request may close these issues.

overrideAttrs on kernel derivation loses passthru values
2 participants